package utils

import "strconv"

func StringToBytes(str string, fixLen int) []byte {
	var b []byte
	if fixLen != 0 {
		if fixLen <= len([]rune(str)) {
			return make([]byte, 0)
		}

		b = make([]byte, fixLen-len([]rune(str)))
	}

	for _, c := range str {
		v, _ := strconv.Atoi(string(c))
		b = append(b, NumberToBytesWithBigEndian[uint8](uint8(v))...)
	}

	return b
}
